#ifndef TIMELINE_KEY_FACTORY_H_INCLUDED
#define TIMELINE_KEY_FACTORY_H_INCLUDED

#include "Singleton.h"
#include "GameObject.h"
#include "GUIObject.h"
#include "ReportError.h"
#include "Timeline.h"
#include <assert.h>



template <class T>
class Factory : public Uncopyable
{
public:
	typedef T* (*Creator) ();
	typedef std::map<std::string, Creator> FactoryMap;
	T* Create(const std::string& typeName)
	{
		Creator c = m_map[typeName];
		assert (c != 0);
		return c();
	}

	bool AddToMap(const std::string& typeName, Creator c)
	{
		m_map[typeName] = c;
		return true;
	}
private:
	Factory() {}
	friend class Singleton<Factory<T>>;
	FactoryMap m_map;
};

typedef Singleton<Factory<GameObject>> TheGameObjectFactory;
typedef Singleton<Factory<GUIObject>> TheGUIObjectFactory;
typedef Singleton<Factory<TimelineKey>> TheTLKFactory;

#endif